<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>{{num}}{{price}}</h1>
        <!-- 使用方法得到 -->
        <div style="border: 1px solid green;">
            <h2>{{priceNum()}}</h2>
            <h2>{{priceNum()}}</h2>
            <h2>{{priceNum()}}</h2>
            <h2>{{priceNum()}}</h2>
        </div>
        <!-- 使用计算属性 -->
        <div style="border: 1px solid red;">
            <h3>{{priceN}}</h3>
            <h3>{{priceN}}</h3>
            <h3>{{priceN}}</h3>
            <h3>{{priceN}}</h3>
        </div>        
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.js"></script>
    <script type="text/javascript">
        var vm = new Vue({
            el:'#app',
            data: {
                num:10,
                price:20
            },
            methods:{
                priceNum(){
                    console.log(1);
                    return this.num * this.price;
                }
            },
            /* 计算属性 */
            computed:{
                priceN(){
                    console.log("计算属性触发");
                    return this.num * this.price;
                }
            }

        });
    </script>
    
</body>
</html>